<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <link rel="stylesheet" type="text/css" href="../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../css/main.css" />
    <script type="text/javascript" src="../script/jquery-1.7.2.min.js"></script>
    <script type="text/javascript" src="../script/api.js"></script>
    <script type="text/javascript" src="../script/mobile.js"></script>
    <script type="text/javascript" src="../script/public.js"></script>
    <script type="text/javascript" src="../script/app.js"></script>
    <title>首页</title>
    <style>
        html,body{

            height: 100%;
        }
    </style>
</head>
<body>
<div class="shouye_ds">
    <p>首页</p>
    <img src="../image/indbg.png" alt="">
    <div class="mian_navsy">
        <ul>
            <li onclick="canplay()">
                <span>
                    <img src="../image/sys.png" alt="">
                    <p>扫一扫</p>
                </span>
            </li>
            <li>
                <span onclick="open_winrs('dinc','dingcan.html');">
                    <img src="../image/dinc.png" alt="">
                    <p>订餐</p>
                </span>
            </li>
            <li>
                <span onclick="open_winrs('shitang','shit_fuk.html');">
                    <img src="../image/stbao.png" alt="">
                    <p>食堂付款</p>
                </span>
            </li>
            <li>
                <span onclick="open_winrs('xiaomaib','xiaomaib_fk.html');">
                    <img src="../image/xmbfk.png" alt="">
                    <p>小卖部付款</p>
                </span>
            </li>
        </ul>
    </div>
    <div class="ind_nalis">

        <ul>
            <li class="chek_nvts" onclick="open_winrs('index','index.html');">
                <span>
                    <img class="shoede_na" src="../image/shouye1.png" alt="">
                    <img src="../image/shouye.png" alt="">
                    <p>首页</p>
                </span>
            </li>
            <li onclick="open_winrs('resrtion','wode_yudin.html');">
                <span>
                    <img class="shoede_na" src="../image/dind1.png" alt="">
                    <img src="../image/dind.png" alt="">
                    <p>预订</p>
                </span>
            </li>
            <li onclick="open_winrs('imgsg','xiaoxi.html');">
                <span class="xiaoxx" id="unread">
                    <img class="shoede_na" src="../image/xiaox1.png" alt="">
                    <img src="../image/xioax.png" alt="">
                    <p>消息</p>
                   
                </span>
            </li>
            <li onclick="open_winrs('myslf','wode.html');">
                <span>
                    <img class="shoede_na" src="../image/wode.png" alt="">
                    <img src="../image/wode.png" alt="">
                    <p>我的</p>
                </span>
            </li>
        </ul>
    </div>
</div>
</body>

<script type="text/javascript">


    window['adaptive'].desinWidth = 750;
    window['adaptive'].baseFont = 28;
    window['adaptive'].maxWidth = 750;
    window['adaptive'].init();

    apiready = function () {

         ajpush();

        // message();
        
        

        $api.fixStatusBar($api.dom('.header'));
        api.addEventListener({
            name: 'keyback'
        }, function(ret, err){
            api.closeWidget();
        });

        if (is_login == 1) {
            //未读消息
            s = {uid:id};
            api.ajax({
                url:webSiteUrl+'/app/user/message',
                method:'post',
                data:{
                    values:s
                }
            },function(ret,err){
                if (ret.code == 200) {

                    if (ret.data.unread != 0 ) {
                        $('#unread').html('<img class="shoede_na" src="../image/xiaox1.png" alt=""><img src="../image/xioax.png" alt=""><p>消息</p><em>'+ret.data.unread+'</em>');
                    }else{
                        $('#unread').html('<img class="shoede_na" src="../image/xiaox1.png" alt=""><img src="../image/xioax.png" alt=""><p>消息</p>');
                    }

                }else{
                    alert(ret.msg);
                }
            });
        }else{
            api.openWin({
                name: 'login',
                url: './login.html',
                reload:true,
                pageParam: {
                    name:'text'
                }
            });
        }




        
        
    }

    

    
   

    function GetUrlParms(query)    

    {

        var args=new Object();   

        var pairs=query.split("&");//在逗号处断开   

        for(var   i=0;i<pairs.length;i++)   

        {   

            var pos=pairs[i].indexOf('=');//查找name=value   

                if(pos==-1)   continue;//如果没有找到就跳过   

                var argname=pairs[i].substring(0,pos);//提取name   

                var value=pairs[i].substring(pos+1);//提取value   

                args[argname]=unescape(value);//存为属性   

        }

        return args;

    }

    function GetUrlParms(query)    
    {

        var args=new Object();   

        var pairs=query.split("&");//在逗号处断开   
        (pairs[0]);
        for(var   i=0;i<pairs.length;i++)   

        {   

            var pos=pairs[i].indexOf('=');//查找name=value   

                if(pos==-1)   continue;//如果没有找到就跳过   

                var argname=pairs[i].substring(0,pos);//提取name  
              

                var value=pairs[i].substring(pos+1);//提取value   

                args[argname]=unescape(value);//存为属性   

        }

        return args;

    }



    //扫一扫
    function canplay(){
        var did = api.deviceId;
       var FNScanner = api.require('FNScanner');
        FNScanner.open({
            autorotation: true
        },function( ret, err ){
            if( ret ){
                if (ret.eventType == 'success') {
                    var d = ret.content;

                    var param = new Object();
                    var url = JSON.stringify(d);

                    var num = url.split("?");

                    param = GetUrlParms(num[1]);
                    
                    var ewm = parseInt(param['ewm']);
                    var tpid = parseInt(param['id']);

                    var b = {uid:id,ewm:ewm,tpid:tpid,did:did};
                    api.ajax({
                        url:webSiteUrl+'/app/record/qrcode',
                        method:'post',
                        data:{
                            values:b
                        }
                    },function(ret,err){
                        if (ret.code == 200) {
                            api.openWin({
                                name: 'zhifu',
                                url: './zhifu_cg.html',
                                reload:true,
                                pageParam: {
                                    balance: ret.data.balance,
                                    total:ret.data.total
                                }
                            });
                        }else{
                            alert(ret.msg);
                        }
                    });
                } else if (ret.eventType == 'fail') {
                        api.toast({msg:'扫描失败，请稍后重试'});
                }
            }else{
                api.toast({msg:err.msg});
            }
        });

  }
   
</script>



</html>